<?php
class mdl_member_history extends ujn_model {
	public function log($mid, $l_sitemid, $r_sitemid, $w) {
		if( !$mid = tls_func::uint($mid) ) {
			return false;
		}
		$w = tls_func::uint($w);
		$l_sitemid = tls_func::escape($l_sitemid);
		$r_sitemid = tls_func::escape($r_sitemid);
		
		$win_sitemid = '';
		$loss_sitemid = '';
		if($w == 0) {
			$win_sitemid = $l_sitemid;
			$loss_sitemid = $r_sitemid;
		}else {
			$win_sitemid = $r_sitemid;
			$loss_sitemid = $l_sitemid;
		}
		$_sql = "INSERT INTO {$this->tbl_name} SET mid = '{$mid}', win_sitemid = '{$win_sitemid}', loss_sitemid = '{$loss_sitemid}', time = '" . NOW . "'";
		$this->_db->query($_sql);
		
		return true;
	}
	
	protected function __construct() {
		parent::__construct();
		$this->db_name		= 'love_a_love';
		$this->tbl_name		= "`{$this->db_name}`.`love_vote_history`";
		$this->_db			= $this->mysql();
	}


    /**
     * 单例模型
     * @return mdl_member_history
     */
	static function getInstance() {
        return parent::getInstance(__CLASS__);
	}	
}